package com.iflytek.universitymanagement.service.impl;


import com.iflytek.universitymanagement.domain.Student;
import com.iflytek.universitymanagement.domain.StudentCounselingStats;
import com.iflytek.universitymanagement.mapper.StudentCounselingStatsMapper;
import com.iflytek.universitymanagement.mapper.StudentMapper;
import com.iflytek.universitymanagement.service.StudentCounselingStatsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author louyp
 * @since 2024-11-26
 */
@Service
public class StudentCounselingStatsServiceImpl extends ServiceImpl<StudentCounselingStatsMapper, StudentCounselingStats> implements StudentCounselingStatsService {

    @Resource
    StudentCounselingStatsMapper studentCounselingStatsMapper;

    @Resource
    StudentMapper studentMapper;

    @Override
    public List<StudentCounselingStats> getAllStudentCounselingStatsWithStudentName() {
        List<StudentCounselingStats> counselingStats1 = studentCounselingStatsMapper.selectStudentCounselingStatsAll();
        for(StudentCounselingStats counselingStats : counselingStats1) {
            Student student = studentMapper.selectById(counselingStats.getStudentId());
            counselingStats.setStudent(student);
        }
        return counselingStats1;
    }

    @Override
    public void deleteCounselingStat(Integer counselingStatsId) {
        studentCounselingStatsMapper.deleteById(counselingStatsId);
    }


}
